﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cherry.Agile.RpcService.Client
{
    /// <summary>
    /// 建立服务请求代理
    /// </summary>
    public abstract class ServiceProxyFactory
    {
        /// <summary>
        /// 创建客户端请求代理
        /// </summary>
        /// <param name="serviceUrl">地址</param>
        /// <param name="isSync">是否同步，默认为false</param>
        /// <returns></returns>
        public static IServiceProxy Create(string serviceUrl,bool isSync=false)
        {
            if (string.IsNullOrEmpty(serviceUrl))
                throw new ArgumentNullException("serviceUrl");
            
            if(isSync)
                return new HttpRequestSyncProxy(serviceUrl);
            else
                return new HttpRequestProxy(serviceUrl);
        }

    }
}
